#pragma once
#include <iostream>
#include <string>
#include "Protocol.hpp"

class Calculator
{
public:
    Calculator()
    {
    }
    response classify(const request &req)
    {
        response resp;
        switch (req.Oper())
        {
        case '+':
            resp.setResult(req.X() + req.Y());
            break;
        case '-':
            resp.setResult(req.X() - req.Y());
            break;
        case '*':
            resp.setResult(req.X() * req.Y());
            break;
        case '/':
        {
            if (req.Y() == 0)
            {
                resp.setCode(1);
            }
            else
            {
                resp.setResult(req.X() / req.Y());
            }
            break;
        }
        case '%':
        {
            if (req.Y() == 0)
            {
                resp.setCode(2);
            }
            else
            {
                resp.setResult(req.X() % req.Y());
            }
            break;
        }
        default:
            resp.setCode(3);
            break;
        }
        return resp;
    }
    ~Calculator()
    {
    }


};